<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use backend\models\AdminInfo;
use backend\models\Image;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\BuildCitySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$width=0;
$height=0;
if(count($vr_pos_main)>0){
    $width=$vr_pos_main[0]["width"];
    $height=$vr_pos_main[0]["height"];
}
$rang=1;
if($width>1000){
    $rang=1000/$width;
}
$max_height=$height*$rang;
$max_width=1000;
?>

<style>
   #vr  table {
        line-height: 40px;
        width: 400px;
        margin-top: 20px;
    }

    #vr  td {
        width: 40px;
        text-align: center;
        border: black 1px solid;
    }
    #vr_buffer{
    	overflow:scroll;
    	width:1650px;
    }
    #vr_buffer td{
	   
      height:50px;
      border: black 1px solid;
      text-align: center;
    }
    
    #buffer_table{
	   width:1650px;
       margin-top:20px;
    } 
    
    .vr_right button{
        width:70px;
        height: 35px;
    }
    .vr_right_top_right button{
	
    	width:85px;
    	height:35px;
    }
    .vr_right_top_right input{
	
    	width:50px;
    }
    
    .vr_right_top_right select{
	
    	width:120px;
    	height:35px;
    }
    .con{
	     margin:0;
    	padding:0;
    	position:relative;
    	height:900px;
    	
    }
    .con div{
	     position:absolute;
    	top:0px;
    	left:0px;
    }
     
</style>

<script>

//点击关闭vr，隐藏当前div,显示菜单
function close_vr(){
	$("#vr").hide();

}
//onclick事件 （vr_exch）
function exch_click_tr(exch_id,x,y){
	$("#exch_id").val(exch_id);
	$("#x").val(x);
	$("#y").val(y);
	var idstr="#"+exch_id+"_exch";
	var div=$(idstr)[0];
	//设置其他边框去掉
	 $("img[name='exch_tab']").each(function(){
         this.style.border="0px";
    });
    
	//设置对应的标签显示外框
	 div.style.border="red 1px solid";
	 //设置其他tr白色，当前tr 背景色
	 $("tr[name='exch_tr']").each(function(){
	        this.style.backgroundColor="white";
	    });
	 var idstr="#"+exch_id+"_exch_tr";
	 var div=$(idstr)[0];
	 div.style.backgroundColor="#1ab8db";
}
//
function exch_tab_click(exch_id){
	$("#exch_id").val(exch_id);
	var idstr="#"+exch_id+"_exch_tr";
	var div=$(idstr)[0];
	 //取消其他tr的样式
    $("tr[name='exch_tr']").each(function(){
        this.style.backgroundColor="white";
    });
    div.style.backgroundColor="#1ab8db";
}
//onclick事件 (主表格）
function get_other_pos(tzid,pos,posid){
    $("#main_pos_id").val(posid);

    $("#tzid").val(tzid);
    $("#pos").val(pos);
    //设置所有的tr背景色为白色
    var idstr="#"+pos+"tr";

    var div=$(idstr)[0];
    $("tr[name='pos_tr']").each(function(){
        this.style.backgroundColor="white";
    });
    //设置当前tr背景色为绿色
    div.style.backgroundColor="#1ab8db";
    $.ajax(
        {url:'index.php?r=vr/get-other-pos',
            data:{'tzid':tzid,'pos':pos},
            success(result){
               result=JSON.parse(result);
               var table_html=" <tr>" +
                   "  <td>图片ID</td> " +
                   "  <td>排序</td> " +
                   "  <td>名称</td> " +
                   "  <td>对应单品</td></tr> ";
               for(var i=0;i<result.length;i++){
                   table_html+="<tr onclick='more_tr_onclick("+result[i].order+","+result[i].id+","+result[i].pos+")' name='pos_more_tr'  id='"+result[i].order+"more_tr'>";
                   table_html+="<td>"+result[i].img_id+"</td>";
                   table_html+="<td>"+result[i].order+"</td>";
                   table_html+="<td>"+result[i].img_name+"</td>";
                   table_html+="<td>"+result[i].item_id+"</td>";
                   table_html+="</tr>";
               }
                $("#vr_pos_more").html(table_html);

            }
        });
}
//onclick事件 （从表格）
function more_tr_onclick(order,posid,pos){
 
    $("#more_pos_id").val(posid);
    var idstr="#"+order+"more_tr";
    var div=$(idstr)[0];
    $("tr[name='pos_more_tr']").each(function(){
        this.style.backgroundColor="white";
    });
    //设置当前tr背景色为绿色
    div.style.backgroundColor="#1ab8db";
    //修改图片
    $.ajax({url:'index.php?r=vr/get-vrpos-img',
        	data:{'id':posid},
        	success(url){
				
				var id_str="#"+pos+"_pos_img";
				$(id_str).attr("src",url);
            }
        });
}
//刷新  从表格数据
function refresh_pos_more(){
    var tzid= $("#tzid").val();
    var pos=$("#pos").val();
    if(tzid==""||tzid==0||pos==0||pos==""){
         alert("请先选择要查看的图层");
    }else{
        $.ajax(
            {url:'index.php?r=vr/get-other-pos',
                data:{'tzid':tzid,'pos':pos},
                success(result){
                    result=JSON.parse(result);
                    var table_html=" <tr>" +
                    "  <td>图片ID</td> " +
                    "  <td>排序</td> " +
                    "  <td>名称</td> " +
                    "  <td>对应单品</td></tr> ";
                    for(var i=0;i<result.length;i++){
                   	 table_html+="<tr onclick='more_tr_onclick("+result[i].order+","+result[i].id+","+result[i].pos+")' name='pos_more_tr'  id='"+result[i].order+"more_tr'>";
                     table_html+="<td>"+result[i].img_id+"</td>";
                     table_html+="<td>"+result[i].order+"</td>";
                     table_html+="<td>"+result[i].img_name+"</td>";
                     table_html+="<td>"+result[i].item_id+"</td>";
                     table_html+="</tr>";
                    }
                    $("#vr_pos_more").html(table_html);

                }
            });
    }
}
//刷新  主表格数据
function refresh_pos_main() {
    var tzid= $("#tzid").val();
    $.ajax(
        {url:'index.php?r=vr/get-main-pos',
            data:{'tzid':tzid},
            success(result){
                result=JSON.parse(result);
                console.log(result);

                var table_html=" <tr> " +
                    "  <td >图片ID</td> " +
                    "  <td>层数</td> " +
                    "  <td>名称</td></tr> ";
                for(var i=0;i<result.length;i++){
                    table_html+="<tr  onclick='get_other_pos("+result[i].tzid+","+result[i].pos+","+result[i].id+")' name='pos_tr' id='"+result[i].pos+"tr'>";
                    table_html+="<td>"+result[i].img_id+"</td>";
                    table_html+="<td>"+result[i].pos+"</td>";
                    table_html+="<td>"+result[i].img_name+"</td></tr>";
                }
                $("#vr_pos_main").html(table_html);

            }
        });
}
//删除  主表格某条数据
function del_pos_main(){
    var pos_id=$("#main_pos_id").val();
    if(pos_id==""||pos_id==0){
        alert("请选择要删除的单元格!");
    }else{
        $.ajax({url:'index.php?r=vr/del-vr-pos',data:{'pos_id':pos_id},success(code){
                refresh_pos_main();
                refresh_pos_more();
            }});

    }


}
//插入 主表格某条数据
function insert_main_pos(){
	 var pos_id=$("#main_pos_id").val();
	 var tzid=<?=$tid?>;
	 if(pos_id==""||pos_id==0){
	        alert("请选择要插入的单元格位置!");
	}else{
		  var tzid=<?=$tid?>;
		  window.location.href='index.php?r=image/index&type=4&tzid='+tzid+'&vr_pos_id='+pos_id; 
		  //window.open('index.php?r=image/index&type=4&tzid='+tzid+'&vr_pos_id='+pos_id );
    }
}

//替换vr_pos的图片
function replace_pos(){
	 var vr_pos_id=$("#main_pos_id").val();
	 var tzid=<?=$tid?>;
	    if(vr_pos_id==""||vr_pos_id==0){
	        alert("请选择要删除的单元格!");
	    }else{
	    	 window.location.href='index.php?r=image/index&type=3&vr_pos_id='+vr_pos_id+'&tzid='+tzid;
	    	//window.open('index.php?r=image/index&type=3&vr_pos_id='+vr_pos_id+'&tzid='+tzid );
		}
}
//删除 从表格某条数据
function del_pos_more(){
    var pos_id=$("#more_pos_id").val();
    if(pos_id==""||pos_id==0){
        alert("请选择要删除的单元格!");
    }else{
        $.ajax({url:'index.php?r=vr/del-vr-pos',data:{'pos_id':pos_id},success(code){
               // refresh_pos_main();
                refresh_pos_more();
            }});

    }
}
//修改选中的vr_pos绑定的item_id
function update_pos_itemid(){
	 var pos_id=$("#more_pos_id").val();
	 var item_id=$("#item_id").val();
	    if(pos_id==""||pos_id==0){
	        alert("请选择要修改的单元格!");
	    }else if(item_id==""||item_id==0){
            alert("请输入有效的单品id");
        }else{
	        $.ajax({url:'index.php?r=vr/up-pos-itemid',data:{'pos_id':pos_id,'item_id':item_id},success(code){
                    refresh_pos_more();
	            }});

	    }
}
//设置默认
function set_default(){
    var pos_id=$("#more_pos_id").val();
    if(pos_id==""||pos_id==0){
        alert("请选择要删除的单元格!");
    }else{
        $.ajax({url:'index.php?r=vr/set-vr-pos-default',data:{'pos_id':pos_id},success(code){
                 refresh_pos_main();
                refresh_pos_more();
            }});
    
    }
	
}
//主图 添加
function add_main_pos(){
    var tzid=<?=$tid?>;
   window.location.href="index.php?r=image/index&type=1&tzid="+tzid;
}
//从图 添加 要获取到当前pos tzid
function add_other_pos() {
    var main_pos_id=$("#main_pos_id").val();
    var tzid=<?=$tid?>;
    if(main_pos_id==""){
        alert("请选择要添加的图层!");return;
    }else{
   		 window.location.href='index.php?r=image/index&type=2&tzid='+tzid+'&vr_pos_id='+main_pos_id;
        //window.open('index.php?r=image/index&type=2&tzid='+tzid+'&vr_pos_id='+main_pos_id ,'width=800,height=600,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');
    }
}

//exch刷新
function exch_refesh(){
	 var tzid= <?=$tid?>;
	    $.ajax(
	        {url:'index.php?r=vr/get-vrexch',
	            data:{'tzid':tzid},
	            success(result){
	                result=JSON.parse(result);
	                var table_html=" <tr> " +
	                    "  <td >层数</td> " +
	                    "  <td>X</td> " +
	                    "  <td>Y</td> " +
	                    "  <td>跳转VR</td> " +
	                    "  <td>跳转图片</td></tr> ";
	                for(var i=0;i<result.length;i++){
	                    table_html+="<tr  onclick='exch_click_tr("+result[i].id+","+result[i].x+","+result[i].y+")' name='exch_tr' id='"+result[i].id+"_exch_tr'>";
	                    table_html+="<td>"+result[i].pos+"</td>";
	                    table_html+="<td>"+result[i].x+"</td>";
	                    table_html+="<td>"+result[i].y+"</td>";
	                    table_html+="<td>"+result[i].goto_url+"</td>";
	                    table_html+="<td>"+result[i].goto_img+"</td></tr>";
	                }
	                $("#vr_exch_table").html(table_html);

	            }
	        });
}
//exch添加
function exch_add(){
    var main_pos_id=$("#main_pos_id").val();
    if(main_pos_id==0||main_pos_id==""){
		alert("请先选择具体层数");
    }else{
    	$.ajax(
        	    {url:'index.php?r=vr/add-exch',
        		data:{'main_pos_id':main_pos_id},
        		success(code){
        			if(code==2){
        				alert("Pos层已存在!");
        		   }else{
        			   exch_refesh();
        		  }
        		}
    		});

    }
    
}
//exch删除
function exch_del(){
	var exch_id=$("#exch_id").val();
	if(exch_id==0||exch_id==""){
		alert("请先选择要删除的单元格!");
   }else{
	   $.ajax(
	       	    {url:'index.php?r=vr/del-exch',
	       		data:{'id':exch_id},
	       		success(code){
	       			if(code==2){
	       				alert("Pos层已存在!");
	       		   }else{
	       			  // exch_refesh();
		       			window.location.reload();
	       		  }
	       		}
	   		});
		
  }
}
//跳转vr添加
function exch_jump_add(){
    var tzid=<?=$tid?>;
	$.ajax({
		url:'index.php?r=vr/add-exch-jump',
		data:{'tzid':tzid},
		success(){
			window.location.reload();

		 }

		});
}
//修改跳转goto_url 当pos>0 不可以修改
function exch_jump_update(){
	var exch_id=$("#exch_id").val();
	var goto_url=$("#goto_url").val();
	if(exch_id==0||exch_id==""){
		alert("请先选择要修改的单元格!");
   }else if(goto_url==""){
		alert("请输入要修改的跳转vr");
   }else{
		$.ajax({

			url:'index.php?r=vr/up-exch-jump',
			data:{'id':exch_id,'goto_url':goto_url},
			success(code){
				  if(code==2){
					alert("图层>0不可操作!");
			     }else{
			    	 window.location.reload();
				 }

		    }
			});
   }
}
//鼠标按下事件  修改x
function up_exch_x(){
	var exch_id=$("#exch_id").val();
	var x=$("#x").val();
	$.ajax({

		url:'index.php?r=vr/up-exch-x',
		data:{'id':exch_id,'x':x},
		success(code){
			exch_refesh();
	    }
		});
}
//鼠标按下事件 修改y
function up_exch_y(){
	var exch_id=$("#exch_id").val();
	var y=$("#y").val();
	$.ajax({
		url:'index.php?r=vr/up-exch-y',
		data:{'id':exch_id,'y':y},
		success(code){
			exch_refesh();
	    }
		});
}
//选择切换点的图片 
function choose_goto_img(){
	var goto_img=$("#goto_img").val();
	var exch_id=parseInt($("#exch_id").val());
	if(exch_id==0){
		alert("请选中要修改的单元格");
    }else{
		$.ajax({url:'index.php?r=vr/up-exch-gotoimg',
				data:{'goto_img':goto_img,'id':exch_id},
				success(code){
				if(code==2){
					alert("该图层不可以设置");
			    }else{
			    	exch_refesh();
			   }
			}});
    }
	 
	
}
//图片标签刷新
function refresh_img(){
	var tzid=<?=$tid?>;
	$.ajax({url:'index.php?r=vr/refresh-img',
			data:{'tzid':tzid},
			success(result){
				result=JSON.parse(result);
				console.log(result);
				var vr_pos_main=result.vr_pos_main;
				var vr_exch=result.vr_exch;
				var table_html="";
				for(var i=0;i<vr_pos_main.length;i++){
					table_html+="<div>";
					table_html+="<img style='width:auto;height:auto;max-height:<?=$max_height?>px;max-width:<?=$max_width?>px;' id='"+vr_pos_main[i].id+"_pos_img'  src="+vr_pos_main[i].img_url+">";
					table_html+="</div>";
				}

				for(var j=0;j<vr_exch.length;j++){
					table_html+="<div style='margin-left:"+vr_exch[j].x*<?=$rang?>+"px;margin-top:"+vr_exch[j].y*<?=$rang?>+"px;'>";
					table_html+="<img width='10px;' onclick='exch_tab_click("+vr_exch[j].id+");' height='20px;' id='"+vr_exch[j].id+"_exch' name='exch_tab' src='<?=Yii::$app->params["webPath"]?>gjj/backend/web/static/images/ic_tab.png'>";
					table_html+="</div>";
				}
				$("#con_img").html(table_html);
				
			}
		});
	
}
//生成查看所有大图，显示操作大图的容器
function show_buffer(){
	$("#vr").hide();
	$("#vr_buffer").show();
	
}
//点击显示buffer图片
function buffer_click(id){
	//设置单元格背景色
    var id_str="#"+id+"_buffer_tr";
    var div=$(id_str)[0];
    $("tr[name='buffer_tr']").each(function(){
        this.style.backgroundColor="white";
    });
    div.style.backgroundColor="#1ab8db";
    
	//生成所有图片列表
	$.ajax({url:'index.php?r=vr/buffer-img',
			data:{'id':id},
			success(result){
				result=JSON.parse(result);
				//console.log(result);
				var imghtml="";
				if(result[0].m_url!=null){
					imghtml+="<img src='<?=Yii::$app->params["webPath"]?>gjj/backend/web/"+result[0].m_url+"'  style='width:400px;height:200px;'/> ";
				}
				if(result[0].b_url!=null){
					imghtml+="<img src='<?=Yii::$app->params["webPath"]?>gjj/backend/web/"+result[0].b_url+"'  style='width:200px;height:200px;'/> ";
				}
				if(result[0].d_url!=null){
					imghtml+="<img src='<?=Yii::$app->params["webPath"]?>gjj/backend/web/"+result[0].d_url+"'  style='width:200px;height:200px;'/> ";
				}
				if(result[0].f_url!=null){
					imghtml+="<img src='<?=Yii::$app->params["webPath"]?>gjj/backend/web/"+result[0].f_url+"'  style='width:200px;height:200px;'/> ";
				}
				if(result[0].l_url!=null){
					imghtml+="<img src='<?=Yii::$app->params["webPath"]?>gjj/backend/web/"+result[0].l_url+"'  style='width:200px;height:200px;'/> ";
				}
				if(result[0].r_url!=null){
					imghtml+="<img src='<?=Yii::$app->params["webPath"]?>gjj/backend/web/"+result[0].r_url+"'  style='width:200px;height:200px;'/> ";
				}
				if(result[0].u_url!=null){
					imghtml+="<img src='<?=Yii::$app->params["webPath"]?>gjj/backend/web/"+result[0].u_url+"'  style='width:200px;height:200px;'/> ";
				}
				$("#img_buffer").html(imghtml);
			}
		});
}
</script>
<input id="id"  type="hidden" value="0"/>
<input id="pos" type="hidden" value="0"/>
<input id="tzid" type="hidden" value="<?=$tid?>"/>

<!---->

<input id="main_pos_id" type="hidden" value="0"/>
<input id="more_pos_id" type="hidden" value="0"/>
<input id="exch_id" type="hidden" value="0"/>   
<!-- 操作vr  -->

    <div id="vr" style=" width:2000px;height:900px;margin-left:-100px; border:red 1px solid;">
    
    <div class="vr_left" style="width:1000px;height:900px;float:left;margin-top:30px;">
   <!--<button onclick="close_vr();">关闭</button>  -->
       <button onclick="refresh_img();">(刷新/查看)</button> <button onclick="show_buffer();">(生成/查看)所有大图</button> <button>(重新生成)VR xml文件</button>
    <span style="color:red;font-size:16px;" id="tz_info"> </span>
    <br/><br/>
    <div class="con"  id="con_img" style="border:green 1px solid;background-color:black;">
        <!-- 所有图层默认单品图显示 -->
       <?php for($i=0;$i<count($vr_pos_main);$i++):?>
        <div> 
        	 <img style="width:auto;height:auto;max-height:<?=$max_height?>px;max-width:<?=$max_width?>px;"  id="<?=$vr_pos_main[$i]["pos"]?>_pos_img"   src="<?=$vr_pos_main[$i]["img_url"]?>"/>
       	</div>
       <?php endfor;?>
       <!-- 所有切换点显示 -->
        
       <?php for($i=0;$i<count($vr_exch);$i++):?>
          <div style="margin-left:<?=$vr_exch[$i]["x"]*$rang?>px;margin-top:<?=$vr_exch[$i]["y"]*$rang?>px;">
           <img width="10px;"  onclick="exch_tab_click(<?=$vr_exch[$i]["id"]?>);" height="20px;" id="<?=$vr_exch[$i]["id"]?>_exch" name="exch_tab"     src="<?=Yii::$app->params["webPath"]?>gjj/backend/web/static/images/ic_tab.png" >
            </div>
       <?php endfor;?>
      
    </div>
    
      
    </div>
    <!-- 操作图片  表格列表 -->
    <div class="vr_right" style="width:900px;height:500px;float:left;">
    	<div class="vr_right_top">
    	    <!--VR上传每层的绑定图片(默认显示)  -->
    		<div class="vr_right_top_left" style="width:400px;height:400px;float: left;overflow: scroll;">
    			 <span style="font-size:16px;color:red;">VR上传每层的绑定图片(默认显示)</span><br/><br/>
    			 <button onclick="refresh_pos_main();">刷新</button> <button onclick="add_main_pos();">添加</button> <button onclick="insert_main_pos();">插入</button> <button onclick="del_pos_main();">删除</button> <button onclick="replace_pos();">替换</button>
    			 <table id="vr_pos_main">
    			 	   <tr>
    			 	   		<td>图片ID</td> 
    			 	   		<td>层数</td>
    			 	   		<td>名称</td>
    			 	   </tr> 
    			 	   <?php for($i=0;$i<count($vr_pos_main);$i++):?>
    			 	   <tr onclick="get_other_pos(<?=$vr_pos_main[$i]["tzid"]?>,<?=$vr_pos_main[$i]["pos"]?>,<?=$vr_pos_main[$i]["id"]?>)" name="pos_tr" id="<?=$vr_pos_main[$i]["pos"]."tr"?>">
    			 	   	    <td><?=$vr_pos_main[$i]["img_id"]?></td>
    			 	   		<td><?=$vr_pos_main[$i]["pos"]?></td>
                            <td><?=$vr_pos_main[$i]["img_name"]?></td>
    			 	   </tr>
    			 	   <?php endfor;?>
    			 </table>
    		</div>
    		<!--VR鼠标点击选择切换点 -->
    		<div class="vr_right_top_right" style="border:green 1px solid;float:left;height:400px;width:500px;overflow: scroll;">
    			<span style="font-size:16px;color:red;">VR鼠标点击选择切换点</span><br/>
    			<button  onclick="exch_refesh();">刷新</button><button onclick="exch_add();">添加</button><button onclick="exch_del();">删除</button>
    			位置X <input id="x" onkeyup="up_exch_x();"/>   位置Y<input id="y" onkeyup="up_exch_y();"/><br/><br/>
    			<button onclick="exch_jump_add();">添加跳转vr</button> <button onclick="exch_jump_update();">修改跳转vr</button> <input id="goto_url"/>
    			<br/><br/>
    			<select onchange="choose_goto_img();" id="goto_img">
    			<option>去客厅.png</option>
    			<option>去主卧.png</option>
    			<option>去次卧.png</option>
        		<option>去书房.png</option>
        		<option>去厨房.png</option>
        		<option>去餐厅.png</option>
        	    <option>去卫生间.png</option>
    			</select>
    			
    			<table id="vr_exch_table" style="width:480px;">
        			<tr>
            			<td>层数</td>
            			<td>X</td>
            			<td>Y</td>
            			<td>跳转VR</td>
            			<td>跳转图片</td>
        			</tr>	
    			    <?php for($i=0;$i<count($vr_exch);$i++):?>
    			    <tr onclick="exch_click_tr(<?=$vr_exch[$i]["id"]?>,<?=$vr_exch[$i]["x"]?>,<?=$vr_exch[$i]["y"]?>);" name="exch_tr" id="<?=$vr_exch[$i]["id"]?>_exch_tr">
    			     	<td><?=$vr_exch[$i]["pos"]?></td>
            			<td><?=$vr_exch[$i]["x"]?></td>
            			<td><?=$vr_exch[$i]["y"]?></td>
            			<td><?=$vr_exch[$i]["goto_url"]?></td>
            			<td><?=$vr_exch[$i]["goto_img"]?></td>
    			    </tr>
    			    <?php endfor;?>
    			</table>
    		</div>
    		
    	</div>
    	<!-- 每层可以替换的图片 -->
    	<div class="vr_right_buttom" style="clear: both;margin-top:60px;">
            <span style="font-size:16px;color:red;">每层可以替换的图片</span><br/><br/>

            <button onclick="refresh_pos_more();">刷新</button> <button onclick="add_other_pos();">添加</button>  <button onclick="del_pos_more();">删除</button> <button onclick="set_default();">设默认</button>

            选择修改对应单品:<input id="item_id" /> <button onclick="update_pos_itemid();">修改</button>
            <br/><br/>
            <table id="vr_pos_more">
                <tr>

                    <td>图片ID</td>
                    <td>排序</td>
                    <td>名称</td>
                    <td>对应单品</td>
                </tr>
              <tr name="pos_tr"><td colspan="6">暂无数据</td></tr>

            </table>



        </div>
    </div>
    </div>
 <!-- 生成大图 -->   
 <script>
 //刷新buffer表格
 function refresh_buffer(){

	 
}
 //清除大图数据
function clear_buffer(){
	var tzid=<?=$tid?>;
	alert(tzid);
	$.ajax({url:'index.php?r=vr/clear-buffer',
		data:{'tzid':tzid},
		success(code){
			alert(code);
			//刷新表格
		}
	});
}

</script>
    <div id="vr_buffer" style=" height: 600px;display:none;">
      
      <button>生成所有大图 </button> <button>下载所有大图</button> <button>上传所有切割资源</button>
      
     <button onclick="refresh_buffer();">刷新</button> <button>生成大图数据</button> <button onclick="clear_buffer();">清除大图数据</button><button>(重新生成)VR xml文件</button>
      
      <table id="buffer_table" >
      <tr>
      	<td>ID</td>
      	<td>套装ID</td>
      	<td>组合排列</td>
      	<td>大图ID</td>
      	<td>切割-B</td>
      	<td>切割-D</td>
      	<td>切割-F</td>
      	<td>切割-L</td>
      	<td>切割-R</td>
      	<td>切割-U</td>
      	<td >上传/下载</td>
      	<td>操作</td>
      </tr>
      <?php for($i=0;$i<count($vr_buffer);$i++):?>
        <tr onclick="buffer_click(<?=$vr_buffer[$i]["id"]?>);"  name="buffer_tr" id="<?=$vr_buffer[$i]["id"]?>_buffer_tr">
      	<td style='width:80px;'><?=$vr_buffer[$i]["id"]?></td>
      	<td style='width:80px;'><?=$vr_buffer[$i]["tzid"]?></td>
      	<td style='width:200px;'><?=$vr_buffer[$i]["pos_list"]?></td>
      	<td style='width:80px;'><?=$vr_buffer[$i]["img_id"]?></td>
      	<td style='width:80px;'><?=$vr_buffer[$i]["img_b"]?></td>
      	<td style='width:80px;'><?=$vr_buffer[$i]["img_d"]?></td>
      	<td style='width:80px;'><?=$vr_buffer[$i]["img_f"]?></td>
      	<td style='width:80px;'><?=$vr_buffer[$i]["img_l"]?></td>
      	<td style='width:80px;'><?=$vr_buffer[$i]["img_r"]?></td>
      	<td style='width:80px;'><?=$vr_buffer[$i]["img_u"]?></td>
      	<td style='width:300px;' ><button>生成大图</button><button>大图下载</button><button>上传切割</button></td>
      	<td style='width:200px;'> </td>
      </tr>
      
      <?php endfor;?>
      
      
      </table>
      
      
    </div>
    <!-- buffer图片显示 -->
    <div id="img_buffer">
    
    
    </div>
    